package com.masterclient.app.modules.shop.adapter;

import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.masterclient.app.R;
import com.masterclient.app.modules.shop.beans.StoreCouponBean;
import com.eoner.baselibrary.utils.Utils;

/**
 * @auther hjian
 * @date 2020/4/9.
 */
public class StoreCouponAdapter extends BaseQuickAdapter<StoreCouponBean, BaseViewHolder> {

    public StoreCouponAdapter() {
        super(R.layout.item_store_coupon);
    }

    @Override
    protected void convert(BaseViewHolder helper, StoreCouponBean item) {
        helper.setGone(R.id.item_store_coupon_verticallayout, getItemCount() != 1)
                .setGone(R.id.item_store_coupon_horizontallayout, getItemCount() == 1)
                .setText(R.id.item_store_coupon_verticaltitle, item.getTitle())
                .setText(R.id.item_store_coupon_horizontaltitle, item.getTitle())
                .setText(R.id.item_store_coupon_verticaldesc, item.getSub_title())
                .setText(R.id.item_store_coupon_horizontaldesc, item.getSub_title())
                .setText(R.id.item_store_coupon_verticaltime, item.getStart_at()+"起可用")
                .setText(R.id.item_store_coupon_horizontaltime, item.getStart_at()+"起可用")
                .setGone(R.id.item_store_coupon_transparent,item.isIs_receive())
                .setText(R.id.item_store_coupon_getvertical,item.isIs_receive()?"已\n领\n取":"立\n即\n领\n取")
                .setText(R.id.item_store_coupon_gethorizontal,item.isIs_receive()?"已领取":"立即领取");
        TextView verticalprice = helper.getView(R.id.item_store_coupon_verticalprice);
        TextView horizontalprice = helper.getView(R.id.item_store_coupon_horizontalprice);
        Utils.setDin(verticalprice, mContext);
        Utils.setDin(horizontalprice, mContext);
        Utils.set_price_style(horizontalprice, "¥ "+item.getAmount(), 0.315f);
        Utils.set_price_style(verticalprice, "¥ "+item.getAmount(), 0.461f);


        FrameLayout root = helper.getView(R.id.item_store_coupon_root);
        ViewGroup.LayoutParams layoutParams = root.getLayoutParams();
        layoutParams.width = ScreenUtils.getScreenWidth() - ScreenUtils.dp2px(120);

    }
}
